﻿#ifndef FORWARD_CONTROL_H
#define FORWARD_CONTROL_H

#include <QObject>
#include <QTcpSocket>
#include <QTcpServer>
#include <QJsonDocument>
#include <QJsonObject>
#include <QVector>
#include <QJsonValue>
#include <Command.hpp>
#include "forward_system.h"
#include "forward_offer.h"


//用于控制不同的访问端
class forward_Control : public QThread
{
    Q_OBJECT
public:
    explicit forward_Control(qintptr client,QObject *parent = nullptr);
    ~forward_Control();
signals:
    
protected:
    void run();
    
private slots:
    void processRequest();  //处理客户请求
    void processDisconnected();  //处理客户断开
    void commandNewPort(QJsonObject &dataObject);  //处理新开端口
    void commandClosePort(QJsonObject &dataObject);  //处理关闭端口
    void commandAddService(QJsonObject info);
private:
    qintptr m_ClientDescriptor;  //socket 描述
    QTcpSocket* m_ClientSocket = nullptr;  //需要转发服务的客户端的socket
    QString m_ClientAddress;
    QVector<int> m_VectorPort;
};

#endif // FORWARD_CONTROL_H
